package cn.hpu.interceptor;

import java.util.Map;

import cn.hpu.po.User;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class LoginInterceptor extends AbstractInterceptor {

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {

		ActionContext acx = invocation.getInvocationContext();
		
		Map<String , Object> session = acx.getSession();
		
		User user = (User) session.get("user");
		
		if(user == null) {
			return Action.LOGIN;
		} else {
			return invocation.invoke();
		}
	}

}
